package com.hbnu.tonghengchang;

import javax.swing.*;
import java.util.Scanner;

public class Login {
    public static void main(String[] args) {
        String uname = "moonoob";
        String upassword = "666";

        Scanner sc = new Scanner(System.in);

        try {
            int i;
            boolean flag = false;
            for (i = 1; i <= 3; i++) {

                System.out.println("请输入您的用户名：");
                String loginName = sc.next();
                System.out.println("请输入您的密码：");
                String loginPassword = sc.next();

                if (uname.equals(loginName)) {
                    if (upassword.equals(loginPassword)) {
                        flag = true;
                        break;
                    } else {
                        System.out.println("用户名或密码输入错误请重新输入！！");
                    }
                } else {
                    System.out.println("用户名或密码输入错误请重新输入！！");
                }
            }
            if (flag == false) System.out.println("您已输错三次用户名或密码，已被禁止登录15分钟！！");
            else System.out.println("欢迎您" + uname + "！！");
        } catch (Exception e) {
            System.out.println("系统发生错误，请重新启动程序！");
        } finally {
            sc.close();
        }


    }
}
